package com.card.admin.servelt;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.card.admin.pojo.AdminManager;
import com.card.advice.AdviceManager;
import com.card.mail.MailManager;
import com.card.notice.NoticeManager;

public class RemoveDataServlet extends HttpServlet {
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse res)
			throws ServletException, IOException {
		res.setContentType("text/plain;charset=utf-8");
		req.setCharacterEncoding("utf-8");
		
		String type = req.getParameter("type");
		String id =  req.getParameter("id");
		System.out.println(type);
		System.out.println(id);
		System.out.println("-------------------------------------******");
		if("adivce".equals(type)){
			AdviceManager.getInstance().deleteAdvice(id);
		}else if("mail".equals(type)){
			MailManager.getInstance().removeMail(id);
		}else if("notice".equals(type)){
			NoticeManager.getInstance().removeNoticeFromDB(id);
		}else if("agent".equals(type)){
			AdminManager.getInstance().changeState(id);
		}else if("agentrm".equals(type)){
			AdminManager.getInstance().deleteAgent(id);
		}
		
	}
	
}
